//新零售与CSRL同Trait AR/TR
//CSRL AR/TR
//新零售开始时间小于等于CSRL零售结束时间，新零售开始时间大于CSRL零售开始时间S2<S1<=E2
//新零售大于CSRL零售

var result_91_2 = JSON.parse('{"CODE":0, "ACTION":"","LEVEL":"", "MSG":"","DATA":"","RULE":"FS_91_2"}');
var S1 = new Date(NEW_RETAIL_EFF_DATE);
var E1 = new Date(NEW_RETAIL_EXP_DATE);
var JSON_LINKSAVE = !isNull(LINKSAVE) ? JSON.parse(LINKSAVE) : [];

//判断存在涨价
function RisePrice(TRAIT_STORE_NBR, RETAIL_TYPE, JSON_CSRL_LIST) {
    for (var i = 0; i < JSON_CSRL_LIST.length; i++) {
        var S2 = new Date(JSON_CSRL_LIST[i].EFFECTIVE_DATE);
        var E2 = new Date(JSON_CSRL_LIST[i].EXPIRATION_DATE);
        if (TRAIT_STORE_NBR == JSON_CSRL_LIST[i].PRICE_TRAIT
            && isARTR(JSON_CSRL_LIST[i].PRICE_TYPE)
            && isARTR(RETAIL_TYPE)
            && betweenDay(S2, S1) > 0 && betweenDay(S1, E2) >= 0
            && NEW_RETAIL > JSON_CSRL_LIST[i].CUST_BASE_RTL_AMT) {
            return true;
        }
    }
    return false;
}
if(!isNull(UPC_NBR) && UPC_NBR.toString().substr(0, 2) == '21') {
    if (!isNull(LINKSAVE)
        && !inSuspendBP(ITEM_NBR, NEW_RETAIL_EFF_DATE, JSON_ITEM_LIST, ID, RETAIL_TYPE)
        && RisePrice(TRAIT_STORE_NBR, RETAIL_TYPE, JSON_CSRL_LIST)
        && LinkSaveRisePriceARTR(JSON_LINKSAVE, RETAIL_TYPE, S1, E1)) {
        result_91_2.CODE = 1;
        result_91_2.ACTION = "APPROVAL_LEVEL";
        result_91_2.LEVEL = "AG";
        result_91_2.MSG = "与Linksave冲突的高风险变价，需GMM审批";
    }
}
JSON.stringify(result_91_2);


